package com.heima.media.controller;

import com.heima.common.dto.ResponseResult;
import com.heima.media.entily.WmUser;
import com.heima.media.service.IWmUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @BelongsProject: heima-leadnews
 * @BelongsPackage: com.heima.media.controller
 * @Author: wangjian
 * @CreateTime: 2022-06-29  00:18
 * @Description: TODO
 * @Version: 1.0
 */
@RestController
@RequestMapping("/api/v1/user")
@Api(tags = "自媒体用户信息表接口")
@CrossOrigin
public class WmUserController {
    @Autowired
    private IWmUserService wmUserService;
    /**
     * 保存自媒体用户
     *
     * @param user
     * @return
     */
    @ApiOperation(value = "saveWmUse",notes = "保存自媒体用户")
    @ApiImplicitParam(value = "媒体用户",paramType = "user",dataType = "WmUser",name = "user")
    @PostMapping
    public ResponseResult<WmUser> saveWmUser(@RequestBody WmUser user) {
        return wmUserService.saveWmUser(user);
    }


    /**
     * @description: 更新自媒体用户
     * @author: wangjian
     * @param: user
     * @return: com.heima.common.dto.ResponseResult
     **/
    @ApiOperation(value = "updateWmUsee",notes = "更新自媒体用户")
    @ApiImplicitParam(value = "媒体用户",paramType = "user",dataType = "WmUser",name = "user")
    @PutMapping
    public ResponseResult updateWmUser(@RequestBody WmUser user) {
        wmUserService.updateById(user);
        return ResponseResult.okResult();
    }

}
